package leetcode.code2211;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int countCollisions(String directions) {
		char[] cs = directions.toCharArray();
		int len = cs.length;
		int ans = 0;
		for (int i = 0; i < len; i++) {
			char cur = cs[i];
			if (cur == 'L') {
				if (i == 0 || cs[i - 1] == 'E') {
					cs[i] = 'E';
				} else {
					ans += 1;
					cs[i] = 'S';
				}
			}
		}
		for (int i = len - 1; i >= 0; i--) {
			char cur = cs[i];
			if (cur == 'R') {
				if (i == len - 1 || cs[i + 1] == 'E') {
					cs[i] = 'E';
				} else {
					ans += 1;
					cs[i] = 'S';
				}
			}
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
